package com.example.zlw.dem4;

import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @program: Zlw
 * @description:
 * @author: 诸葛龙辰
 * @create: 2022-11-04 21:05
 **/

/**
 * 构造方法引用练习
 */
public class Test {
    public static void main(String[] args) {
        //lambda表达形式
        //Function<String,School>  function=t->new School(t);
        //构造方法引用
        Function<String,School> function=School::new;
        String name="中国人民警校";
        School apply = function.apply(name);
        System.out.println(apply);


        Supplier<School> supplier=()->new School("哦哦哦");
        System.out.println(supplier.get());
    }
}
class School{
    private String name;

    public School(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "School{" +
                "name='" + name + '\'' +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
